package cp8_pool;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import util.Constants;
import util.DataSourceTool;

import javax.sql.*;
import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.Properties;

public class C3P0Test {
    public static void main(String[] args) throws Exception {
        ComboPooledDataSource ds = new ComboPooledDataSource();
        // 设置数据连接的信息
//        ds.setDriverClass("com.mysql.cj.jdbc.Driver");
//        ds.setJdbcUrl(Constants.URL);// 连接字符串
//        ds.setUser(Constants.USERNAME);
//        ds.setPassword(Constants.PASSWORD);
//        // 设置数据库连接池的相关信息
//        ds.setMaxPoolSize(20);//最大20个连接
//        ds.setMinPoolSize(10);//最小10个连接
//        ds.setInitialPoolSize(5);
        //
        Connection connection = ds.getConnection();

        DatabaseMetaData metaData = connection.getMetaData();
        String databaseProductName = metaData.getDatabaseProductName();
        int databaseMinorVersion = metaData.getDatabaseMinorVersion();

        System.out.println("服务器信息:" + databaseProductName + "==>" + databaseMinorVersion);
        connection.close();
    }
}
